﻿@inject IStringLocalizer<DialogKeyboard> Localizer

<Button OnClick="@OnClick">@Localizer["KeyboardOpenDialogButton"]</Button>
<Button OnClick="@OnClickKeyboard" Text="@($"Keyboard: {IsKeyboard}")" class="ms-3" />

@code {
    [Inject]
    [NotNull]
    private DialogService? DialogService { get; set; }

    private bool IsKeyboard { get; set; }

    private Task OnClick() => DialogService.Show(new DialogOption()
    {
        IsKeyboard = IsKeyboard,
        Title = "I am the popup created by the service",
        BodyTemplate = BootstrapDynamicComponent.CreateComponent<Button>(new Dictionary<string, object?>
        {
            [nameof(Button.ChildContent)] = new RenderFragment(builder => builder.AddContent(0, "Button"))
        }).Render()
    });

    private void OnClickKeyboard()
    {
        IsKeyboard = !IsKeyboard;
    }
}
